package cn.tedu.cgb2110boot01;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet //浏览器的默认访问规则是和类名保持一致 /Servlet4
public class Servlet4 extends HttpServlet {
    //Servlet的生命周期:三个阶段init()   destroy()  service()
    //会执行多次,访问几次Servlet这个service()就会执行几次.
    //用来接受请求,给浏览器做出响应
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取请求方式
        String method = req.getMethod();
        System.out.println("service()开始服务..."+method);
    }

    @Override
    public void destroy() {

        System.out.println("destroy()开始销毁...");
    }

    @Override
    public void init() throws ServletException {

        System.out.println("init()开始初始化...");
    }


}
